// pages/withdrawaloptions/withdrawaloptions.js
var GlobalData = require('../../utils/GlobalData.js');
var dataManager = require('../../utils/dataManager.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    withDrawTypeInfo: [{ bankName: '银行卡', trueName: "", account: "请绑定银行卡", img: "yhk", type: 1, ishasData: false }, { bankName: '微信', trueName: "", account: "微信红包", img: "weixin2", type: 5, ishasData: true }],
    isWithdrawDeposit: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (GlobalData.bindInfo.length) {
      for (let i = 0; i < GlobalData.bindInfo.length; i++) {
        if (GlobalData.bindInfo[i].type == 1) {
          this.data.withDrawTypeInfo[0] = GlobalData.clone(GlobalData.bindInfo[i])
          this.data.withDrawTypeInfo[0].img = "yhk";
          this.data.withDrawTypeInfo[0].ishasData = true;
          this.setData({
            'withDrawTypeInfo[0]': this.data.withDrawTypeInfo[0],
          });
          break;
        }
      }
    }
    // for (let j = 0; j < this.data.withDrawTypeInfo.length; j++) {
    //   if (this.data.withDrawTypeInfo[j].type == 5 && !app.getConfig().isWithdrawDeposit) {

    //     this.data.withDrawTypeInfo.splice(j, 1)
    //   }
    // }
    this.setData({
      withDrawTypeInfo: this.data.withDrawTypeInfo,
    });
    console.log(this.data.withDrawTypeInfo)
  },
  bindBankCard(e) {
    let item = e.currentTarget.dataset.item
    if (item.type == 1 && !item.ishasData) {
      dataManager.UseNavigateTo("/pages/component/homes/bindbankcard/bindbankcard?url=withdrawaloptions", false)
    } else {
      //返回上一级
      GlobalData.withDrawType = item
      wx.navigateBack({
        delta: 1
      })
    }
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})